#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

typedef struct link Link;

struct link
{
     int data;
     struct link *next;
};


Link *creat()
{
        int c;
        Link *head, *s, *r;
        head = (Link*)malloc(sizeof(Link));
        r = head;
        scanf("%d", &c);
        while(c != -1)
        {
                s = (Link*)malloc(sizeof(Link));
                s->data = c;
                r->next = s;
                r = s;
                scanf("%d", &c);
        }
        r->next = '\0';
        return head;
}

void print(Link *head)
{
	Link *p;
	p = head->next;
	if(p == '\0')
		printf("LinkList is null\n");
	else
	{
		printf("head");
		do
		{
			printf("---->%d", p->data);
			p = p->next;
		}while(p != '\0');
		printf("---->end\n");
	}
}

void insert(Link *head, int x, int y)
{
	Link *s, *p, *q;
	s = (Link*)malloc(sizeof(Link));
	s->data = y;
	q = head;
	p = head->next;
	while((p != '\0') && (p->data != x))
	{
		q = p;
		p = p->next;
	}
	s->next = p;
	q->next = s;
}

void  SetNull(Link *head)
{
	head = NULL;
}

void main()
{
	Link *head;
	head = creat();
	print(head);
	insert(head, 5, 50);
	print(head);
	SetNull(head);
	print(head);
}


